From: W. Michael Petullo Date: Wed, 25 May 2011 09:45:24 +0000 (+0100) Subject: tools/hotplug: support vif-post.d hook arrangements X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~10296 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=8b917cf2d04c187f1fbfc1363d9c962bfbd7434c;p=xen.git tools/hotplug: support vif-post.d hook arrangements New feature: you can drop hook scripts into /etc/xen/scripts/vif-post.d/*.hook Acked-by: Ian Campbell Committed-by: Ian Jackson --- diff --git a/tools/hotplug/Linux/vif-bridge b/tools/hotplug/Linux/vif-bridge index 1498805379..f48951935a 100644 --- a/tools/hotplug/Linux/vif-bridge +++ b/tools/hotplug/Linux/vif-bridge @@ -105,6 +105,8 @@ if [ "$type_if" = vif ]; then handle_iptable fi +call_hooks vif post + log debug "Successful vif-bridge $command for $dev, bridge $bridge." if [ "$type_if" = vif -a "$command" = "online" ] then diff --git a/tools/hotplug/Linux/vif-nat b/tools/hotplug/Linux/vif-nat index 9082cc96bb..8d29fb6ea2 100644 --- a/tools/hotplug/Linux/vif-nat +++ b/tools/hotplug/Linux/vif-nat @@ -185,6 +185,8 @@ esac handle_iptable +call_hooks vif post + log debug "Successful vif-nat $command for ${dev}." if [ "$command" = "online" ] then diff --git a/tools/hotplug/Linux/vif-post.d/00-vif-local.hook b/tools/hotplug/Linux/vif-post.d/00-vif-local.hook new file mode 100644 index 0000000000..d7d44535e2 --- /dev/null +++ b/tools/hotplug/Linux/vif-post.d/00-vif-local.hook @@ -0,0 +1,18 @@ +#============================================================================ +# ${XEN_SCRIPT_DIR}/vif-post.d/00-vif-local.hook +# +# Script for performing local configuration of a vif. +# This script will be sourced by, e.g., vif-bridge after the hotplugging +# system calls vif-bridge. The script is here and not simply executed as +# a udev rule because this allows simple access to several environment +# variables set by the calling vif-* script. +# +# Environment vars: +# command (add|remove|online|offline) +# dev vif interface name (required). +# main_ip IP address of Dom0 +# ip list of IP networks for the vif, space-separated +# XENBUS_PATH path to this device's details in the XenStore (required). +#============================================================================ + +# Place local modifications here. diff --git a/tools/hotplug/Linux/vif-route b/tools/hotplug/Linux/vif-route index 6c5587afd5..02f1403a54 100644 --- a/tools/hotplug/Linux/vif-route +++ b/tools/hotplug/Linux/vif-route @@ -49,6 +49,8 @@ fi handle_iptable +call_hooks vif post + log debug "Successful vif-route ${command} for ${dev}." if [ "${command}" = "online" ] then diff --git a/tools/hotplug/Linux/xen-hotplug-common.sh b/tools/hotplug/Linux/xen-hotplug-common.sh index 370f9ade2f..95beab0ec5 100644 --- a/tools/hotplug/Linux/xen-hotplug-common.sh +++ b/tools/hotplug/Linux/xen-hotplug-common.sh @@ -99,4 +99,15 @@ xenstore_write() { _xenstore_write "$@" || fatal "Writing $@ to xenstore failed." } +## +# call_hooks +# +# Execute each hook in the directory. +# +call_hooks() { + for f in /etc/xen/scripts/${1}-${2}.d/*.hook; do + [ -x "$f" ] && . "$f" + done +} + log debug "$@" "XENBUS_PATH=$XENBUS_PATH"